<?php
/**
 * 公共方法
 * @author GL
 * @date 2018.8.23
 */


/**
 * 密码md5加密
 * @param $salt
 * @param $pass
 */
function pass_md5($salt,$pass)
{
    if($salt && $pass){
        return md5(config('pass.salt').$salt.$pass);
    }

    return false;
}

//菜单分类
if (! function_exists('getTree')) {
    function getTree($data, $first, $menu_as, $parent_id = '0')
    {
        $arr = [];
        foreach($data as $k=>$v){

            if($v['parent_id'] == $parent_id)
            {
                if($v['parent_id'] == 0 && $v['menu_as'] == $first){
                    $v['cur'] = 1;
                }
                if($v['menu_as'] == $menu_as){
                    $v['cur'] = 1;
                }
                $v['small'] = getTree($data, $first, $menu_as, $v['menu_id']);
                if(empty($v['small'])){
                    unset($v['small']);
                }
                $arr[] = $v;
            }
        }
        return $arr;
    }
}